package httpx

import (
	"crypto/tls"
	"time"

	"github.com/go-resty/resty/v2"
)

type Option func(cli *resty.Client)

// WithTimeout 超时时间
func WithTimeout(sec int) Option {
	return func(cli *resty.Client) {
		if sec > 0 {
			cli.SetTimeout(time.Second * time.Duration(sec))
		}
	}
}

// WithRetryCount 重试次数
func WithRetryCount(cnt int) Option {
	return func(cli *resty.Client) {
		if cnt > 0 {
			cli.SetRetryCount(cnt)
		}
	}
}

// WithSkipTLS 跳过证书认证
func WithSkipTLS() Option {
	return func(cli *resty.Client) {
		cli.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
	}
}
